@extends('layouts.public')

@section('bodyattr')class="gray-bg"@endsection

@section('body')
    <div class="wrapper wrapper-content">
        <div class="row m-b">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="{{route('admin.forum.forums')}}">论坛列表</a></li>
                        <li><a href="{{route('admin.forum.forums.add')}}">新增</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <form role="form" class="form-inline" method="get">
                            <div class="form-group">
                                <label class="sr-only">论坛搜索</label>
                                <input type="text" name="title" placeholder="标题/作者" class="form-control" value="{{request('title')}}">
                            </div>
                            &nbsp;&nbsp;
                            <div class="form-group">
                                <input placeholder="请选择发布时间范围" class="form-control" id="created_at" type="text" name="created_at" value="{{request('created_at')}}" style="width: 200px;"
                                       autocomplete="off">
                            </div>
                            <button type="submit" class="btn btn-primary">搜索</button>
                            <button type="button" class="btn btn-white" onclick="location.href='{{route('admin.forum.forums')}}'">重置</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                            <thead>
                            <tr role="row">
                                <th>ID</th>
                                <th>头像</th>
                                <th>标题</th>
                                <th>作者</th>
                                <th>阅读量</th>
                                <th>评论量</th>
                                <th>状态</th>
                                <th class="sorting" orderby="created_at">创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            @foreach($forums as $user)
                                <tr class="gradeA">
                                    <td>{{$user['id']}}</td>
                                    <td><img src="{{$user['avatar']}}" alt=""></td>
                                    <td>{{$user['title']}}</td>
                                    <td>{{$user['nickname']}}</td>
                                    <td>{{$user['views']}}</td>
                                    <td>{{$user['comment_num']}}</td>
                                    <td>
                                        @if($user['status']=='0')<span style="color:orange">待审核</span>@endif
                                            @if($user['status']=='1')<span style="color:green">进行中</span>@endif
                                            @if($user['status']=='2')<span style="color:gray">审核失败</span>@endif
                                            @if($user['status']=='3')<span style="color:#333">已完成</span>@endif
                                    </td>
                                    <td>{{$user['created_at']}}</td>
                                    <td>
                                        <a href="{{route('admin.forum.forums.edit',[$user->id])}}">编辑</a>|
                                        <a href="{{route('admin.forum.forums.comment',[$user->id])}}">评论</a>|
                                       @if ($user['status']!=1)
                                        <a href="{{route('admin.forum.forums.shen',[$user->id])}}">审核</a>|
                                        @endif
                                         <a class="ajaxBtn" href="javascript:void(0);" uri="{{route('admin.forum.forums.delete',[$user->id])}}" msg="是否删除该话题？">删除</a>
                                    </td>
                                </tr>
                            @endforeach
                        </table>
                        <div class="row">
                            <div class="col-sm-12">
                                <div>共 {{ $forums->total() }} 条记录</div>
                                {!! $forums->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript" src="{{cdn('js/plugins/laydate/laydate.js')}}"></script>
    <script type="text/javascript">
        laydate.render({
            elem: '#created_at',
            range: true,
            max: 0
        });
    </script>
@endsection
